package cn.lg.soar.system.api.service;

import cn.lg.soar.system.api.model.AuthRole;
import cn.lg.soar.system.api.model.RoleDTO;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author luguoxiang
 * @date 2022/1/2
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public interface IRoleApi {

    List<Long> idsByUserId(Long userId);

    List<Long> idsByOrgId(Long orgId);

    List<Long> idsByPostId(Long postId);

    List<RoleDTO> listByCodes(List<String> codes);

    List<RoleDTO> listByIds(List<Long> ids);

    RoleDTO getById(Long id);

    List<String> codesByIds(List<Long> roleIds);

    List<AuthRole> userRoleList(Long userId);

    default Map<Long, RoleDTO> mapByIds(List<Long> ids) {
        return listByIds(ids).stream().collect(Collectors.toMap(RoleDTO::getId, x -> x));
    }

}
